package com.feiyuan.core.controller.admin;

import com.feiyuan.common.result.R;
import com.feiyuan.core.annotation.FeiyuanRequiresPermissions;
import com.feiyuan.core.feignClients.AdminClassifyFeignClient;
import com.feiyuan.core.feignClients.entity.UmsClassify;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/core/classify")
public class AdminClassifyController {

    @Autowired
    private AdminClassifyFeignClient classifyFeignClient;

    /**
     * 查询列表
     * @return
     */
    @GetMapping("/list")
    @FeiyuanRequiresPermissions("admin:classify:list")
    public R list() {
        return classifyFeignClient.list();
    }

    /**
     * 查询上级分类
     * @return
     */
    @GetMapping("/listUpClassify")
    @FeiyuanRequiresPermissions("admin:classify:listUpClassify")
    public R listUpClassify() {
        return classifyFeignClient.listUpClassify();
    }

    /**
     * 保存或者修改
     * @param umsClassify
     * @return
     */
    @PostMapping("/saveOrUpdate")
    @FeiyuanRequiresPermissions("admin:classify:saveOrUpdate")
    public R saveOrUpdate(@RequestBody UmsClassify umsClassify) {
        return classifyFeignClient.saveOrUpdate(umsClassify);
    }

    /**
     * 查询详情
     * @param id
     * @return
     */
    @GetMapping("/info/{id}")
    @FeiyuanRequiresPermissions("admin:classify:info")
    public R info(@PathVariable Long id) {
        return classifyFeignClient.info(id);
    }
}
